/*
 * GeneralAIData.cpp
 *
 *  Created on: Sep 9, 2017
 *      Author: gaoyi
 */

#include "AIData.h"
#include "GeneralAIData.h"

#include "Character/monster/Monster.h"

GeneralAIData::GeneralAIData(Creature* pMaster):AIData(pMaster)
{

}

GeneralAIData::~GeneralAIData()
{

}

bool GeneralAIData::Init()
{
	if (GetMaster()->CreatureKind() == CREATURE_MONSTER)
	{
		Monster* pMonster = dynamic_cast<Monster*>(GetMaster());
		if (pMonster && pMonster->GetParentMonsterType() == PARENT_MONSTER_TYPE_MONSTER)
		{
			SetMasterMonster(pMonster);
		}
		else
		{
			return false;
		}
	}
	else
	{
		return false;
	}

	SetMoveType(AI_MOTION_MODE_WALK);						//移动类型
	SetMoveSpeed(GetMasterMonster()->GetMonsterInfo()->mSpeed/1000.0f);
	SetRunSpeed(GetMasterMonster()->GetMonsterInfo()->rSpeed/1000.0f);

	SetPatrolType(GetMasterMonster()->GetMonsterInfo()->patrolType);
	SetRestTimeData(GetMasterMonster()->GetMonsterInfo()->bodyStayTime);
	SetBornProtectTime(GetMasterMonster()->GetMonsterInfo()->bornEffectAIDelay);

	if (GetMasterMonster()->GetMonsterFightType() == ENUM_MONSTER_FIGHT_TYPE_NO_ATTACK)
	{
		SetCanAttack(false);
		SetCanMove(false);
	}
	else
	{
		SetCanAttack(true);
		SetCanMove(true);
		if (GetMasterMonster()->GetMonsterFightType() == ENUM_MONSTER_FIGHT_TYPE_ATTACK_AFTER_ATTACK)
		{
			SetAttackType(BE_ATTACKED_ATTACK);
		}
		else if (GetMasterMonster()->GetMonsterFightType() == ENUM_MONSTER_FIGHT_TYPE_ACTIVE_ATTACK)
		{
			SetAttackType(AUTO_ATTACK);
		}
		else
		{
			SetAttackType(AUTO_ATTACK);
		}
	}
	return true;
}

